package com.wnhoo.smartfishtank.api;


import com.wnhoo.smartfishtank.api.other.JSONUtil;
import com.wnhoo.smartfishtank.util.MyLog;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;

/**
 * Created by kevinwen on 2015/3/2.
 * Copyright (c) 2015/3/2.KevinWen. All rights reserved.
 */
public class LM_DebugCheck {

    private final static String url = LM_BasicAPI.BASE_JSON_URL+"/plug/debug.json";

    public static boolean isDebug( ) throws ClientProtocolException, IOException {

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        HttpResponse response = httpclient.execute(post);
        HttpEntity entity = response.getEntity();

        String json = JSONUtil.getJSONString(entity);
        MyLog.TT("Test", "json[" + json);
        if(json!=null&&json.indexOf("{\"debug\":1}")!=-1){
        //if(json!=null&&json.equals("{\"debug\":1}")){
            MyLog.TT("Test", "return true;");
            return true;
        }
        MyLog.TT("Test", "return false");
        return false;
    }
}
